module(..., package.seeall)
local logtag = 'KEY5'
-- 产生中断时自动调用intFnc(msg)函数：上升沿中断时：msg为cpu.INT_GPIO_POSEDGE；下降沿中断时：msg为cpu.INT_GPIO_NEGEDGE
-- 执行getInputFnc()即可获得当前电平；如果是低电平，getInputFnc()返回0；如果是高电平，getInputFnc()返回1
keys = {M = 0, DI1 = 1, DI2 = 2}
function process(kv, m)
    if m == cpu.INT_GPIO_NEGEDGE then
        log.warn(logtag, 'key_val', kv,m)
        sys.publish("DTU_KEY_PRESS_"..kv, kv, m)
        sys.publish("SYS_BEEP",100)
    end
end
function key_M(m) process(keys.M,m) end
function DI1(m) process(keys.DI1,m) end
function DI2(m) process(keys.DI2,m) end
pins.setup(27, DI1) --DI1
pins.setup(28, DI2) --DI2
pins.setup(23, key_M)  --key
